/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.colegiatura.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.general.bc.CargoFacadeLocal;
import org.cip.esymons.general.be.Area;
import org.cip.esymons.general.be.Cargo;

/**
 *
 * @author ADMINISTRADOR
 */
public class CargoDelegate {

    private CargoFacadeLocal local;

    public CargoDelegate() {

        local = lookupCargoFacade();
    }

    public void create(Cargo cargo){

        local.create(cargo);
    }

    public void edit(Cargo cargo){

        local.edit(cargo);
    }

    public void remove(Cargo cargo){

        local.remove(cargo);
    }

    public Cargo find(Object id){

        return local.find(id);
    }

    public List<Cargo> findAll(){

        return local.findAll();
    }

    public List<Cargo> buscaCargoPorArea(Integer area){

        return local.listaCargoPorArea(area);
    }

    public List<Cargo> buscaCargosPorAreas(Area area){

        return local.listaCargosPorAreas(area);
    }

    private CargoFacadeLocal lookupCargoFacade() {
        try {
            Context c = new InitialContext();
            return (CargoFacadeLocal) c.lookup("java:comp/env/CargoFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }



}
